package me.haoliang

/**
  * author: planck 
  * createTime: 2016/10/12.
  */
object ArrayScala {
  def main(args: Array[String]): Unit = {
    //第一种
    val z = new Array[String](3)

    z(0) = "a"
    z(1) = "b"
    z(2) = "c"

    //第二种
    val zz = Array("a", "b", "c")

    //foreach
    zz.foreach(a => println(a))

    //steam
    val zzz = zz.toStream.filter(a => !a.equals("c")).toList;
    zzz.foreach(a => println(a))

    //元组
    val t = new Tuple3(1, 2.1, "aaa")
    //调用前两个
    val sum = t._1 + t._2
    //也是可以循环的
    t.productIterator.foreach(a => println(a))


    //map
    var a: Map[String, String] = Map()

    //Map是不可变的集合 所以增加操作会返回一个不同的对象。而不是在原有对象上操作
    a += ("aaa" -> "aaa")
    a += ("bbb" -> "aa")
    a += ("ccc" -> "vv")

    //map遍历
    a.keys.foreach(bb => printf("key = %s value = %s\n", bb, a(bb)))




  }
}
